package com.ly.common.baserx;

import com.ly.common.basebean.BaseResponse;

import rx.functions.Func1;

/**
 * Created by admin on 2017/4/5.
 */

public class RxResponseFuncForCar<T> implements Func1<Object, T> {

    private static final String RESP_OK = "ok";

    //此处逻辑根据约定报文进行修改，实现逻辑即可
    @Override
    public T call(Object httpResult) {
        BaseResponse<T> response = (BaseResponse<T>)httpResult;
        if (!response.success()) {
            // 在此处抛出异常，subscribe的onError方法中会收到异常。
            // 抛出的异常不能是会使系统崩溃的检查异常，如OOM
            throw new IllegalStateException(response.status);
        }
        return response.data;
    }

}